<template>
  <div style="width: 100%; height: 100%">
    <el-breadcrumb
      separator-class="el-icon-arrow-right"
      class="breadcrumb-base"
      style="line-height: 30px"
    >
      <el-breadcrumb-item :to="{ path: '/institution/user' }">
        <i class="el-icon-user"></i>
        用户信息
      </el-breadcrumb-item>
      <el-breadcrumb-item>编辑用户</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="add-board main-container">
      <el-form ref="refForm" :rules="stepOneFormRules" :model="form" label-width="140px">
        <el-tabs v-model="activeName" type="card">
          <el-tab-pane label="基本信息" name="basicInformation">
            <span class="title-medium text-important">基础信息</span>
            <el-row class="row-class">
              <el-col :span="6">
                <el-form-item label="用户头像">
                  <el-upload
                    :before-upload="beforeAvatarUpload"
                    :limit="1"
                    accept=".jpg, .png, .bmp"
                    class="avatar-uploader"
                    :action="userAvatorUrl"
                    ref="addItemDataUpload"
                    :on-success="handleAvatarSuccess"
                    :show-file-list="false"
                    :drag="true"
                  >
                    <img
                      v-if="form.headUrl"
                      :src="
                                                imageServiceURL + form.headUrl
                                            "
                      class="avatar"
                      alt
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    <div
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="18" class="dimspace">
                <el-row class="row-padding-bottom">
                  <el-col :span="8">
                    <el-form-item label="姓名" prop="name">
                      <el-input placeholder="用户姓名" v-model="form.name" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="手机" prop="phone">
                      <el-input placeholder="手机号码" v-model.number="form.phone" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="所属机构">
                      <el-select
                        v-model="form.institutionId"
                        size="mini"
                        style="width: 100%"
                        placeholder="请选择"
                        :disabled="isOrgAdmin"
                      >
                        <el-option
                          v-for="t in institutionsData"
                          :key="t.value"
                          :label="t.label"
                          :value="t.value"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row class="row-padding-bottom">
                  <el-col :span="8">
                    <el-form-item label="身份证" prop="idCard">
                      <el-input placeholder="身份证号" v-model="form.idCard" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="医生工号" prop="jobNumber">
                      <el-input placeholder="医生工号" v-model="form.jobNumber" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="所在地">
                      <el-cascader
                        size="mini"
                        style="width: 100%"
                        :options="areaOptionsData"
                        :props="props"
                        :clearable="true"
                        v-model="area"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row class="row-padding-bottom">
                  <el-col :span="8">
                    <el-form-item label="学历" prop="education">
                      <el-input placeholder="学历" v-model="form.education" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="专业" prop="major">
                      <el-input placeholder="专业" v-model="form.major" size="mini" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="性别">
                      <el-radio-group v-model="form.gender">
                        <el-radio
                          v-model="form.gender"
                          v-for="(
                                                        ele, index
                                                    ) in sexDate"
                          :key="index"
                          :label="ele.dicCode"
                        >{{ ele.dicName }}</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <span class="title-medium text-important">角色</span>
            <el-row class="row-class row-padding-role">
              <el-col :span="11">
                <el-form-item label="角色" prop="roles">
                  <el-select
                    v-model="roles"
                    multiple
                    @change="ifEditPermission"
                    size="mini"
                    style="width: 100%"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in userGroupsList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <div v-show="!isPermissionEdit">
              <span class="title-medium text-important">院内诊断权限（诊断组）</span>
              <el-row class="row-class row-margin-left">
                <el-col :span="4">
                  <el-form-item label="院内诊断冰冻权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isFreezePermissions"
                      style="width: 100%"
                      placeholder="请选择冰冻权限"
                    >
                      <el-option
                        v-for="s in freezePermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="4">
                  <el-form-item label="科内会诊申请权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isDivisionConsultationApplyPermissions"
                      style="width: 100%"
                      placeholder="请选择科内会诊申请权限"
                    >
                      <el-option
                        v-for="s in freezePermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="院外会诊申请权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isOutsideConsultationApplyPermissions"
                      style="width: 100%"
                      placeholder="请选择院外会诊申请权限"
                    >
                      <el-option
                        v-for="s in freezePermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row class="row-class row-margin-left">
                <el-col :span="4">
                  <el-form-item label="院外会诊诊断权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isOutsideConsultationApplyDiagnosisPermissions"
                      style="width: 100%"
                      placeholder="请选择院外会诊诊断权限"
                    >
                      <el-option
                        v-for="s in freezePermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="妇科细胞诊断权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isGynaecologyCellDiagnosisPermissions"
                      style="width: 100%"
                      placeholder="请选择妇科细胞诊断权限"
                    >
                      <el-option
                        v-for="s in freezePermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="切片检索权限">
                    <el-select
                      size="mini"
                      :disabled="isPermissionEdit"
                      v-model="form.isBiopsyRetrieval"
                      style="width: 100%"
                      placeholder="请选择切片检索权限"
                    >
                      <el-option
                        v-for="s in biopsyRetrievalPermissionsList"
                        :key="s.id"
                        :label="s.label"
                        :value="s.id"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- <el-row class="row-class">
                                <el-col :span="11">
                                    <el-form-item label="系统病理诊断权限">
                                        <el-select
                                            size="mini"
                                            clearable
                                            :disabled="false"
                                            v-model="Permissionvalue"
                                            style="width: 100%"
                                        >
                                            <el-option
                                                v-for="s in innerPermission"
                                                :key="s.level"
                                                :label="s.label"
                                                :value="s.level"
                                            />
                                        </el-select>
                                    </el-form-item>
                                </el-col>
              </el-row>-->
              <el-row class="row-class">
                <el-col :span="11">
                  <el-form-item label="初诊">
                    <el-select
                      v-model="initialDiagnosis"
                      filterable
                      :multiple="multiple"
                      size="mini"
                      :disabled="isPermissionEdit"
                      style="width: 100%"
                      placeholder="初诊"
                    >
                      <el-option
                        v-for="s in subGroupsData"
                        :key="s.id"
                        :label="s.name"
                        :value="s.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="2" :offset="1">
                  <el-button
                    size="mini"
                    type="primary"
                    @click="initialDiagnosisChooseAll"
                    :disabled="isPermissionEdit"
                    style="margin-top: 5px"
                  >全选</el-button>
                </el-col>
              </el-row>
              <el-row class="row-class">
                <el-col :span="11">
                  <el-form-item label="核发">
                    <el-select
                      v-model="approveIssues"
                      filterable
                      :multiple="multiple"
                      size="mini"
                      :disabled="isPermissionEdit"
                      style="width: 100%"
                      placeholder="核发"
                    >
                      <el-option
                        v-for="s in subGroupsData"
                        :key="s.id"
                        :label="s.name"
                        :value="s.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="2" :offset="1">
                  <el-button
                    size="mini"
                    type="primary"
                    @click="approveIssuesChooseAll"
                    :disabled="isPermissionEdit"
                    style="margin-top: 5px"
                  >全选</el-button>
                </el-col>
                <!-- <el-col :span="4">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifReport"
                                        active-text="是否能发肿瘤报告"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifCytology"
                                        active-text="细胞学诊断"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifFrozen"
                                        active-text="冰冻诊断权限"
                                    />
                </el-col>-->
              </el-row>
              <el-row class="row-class">
                <el-col :span="11">
                  <el-form-item label="审核">
                    <el-select
                      v-model="examine"
                      filterable
                      :disabled="isPermissionEdit"
                      :multiple="multiple"
                      size="mini"
                      style="width: 100%"
                      placeholder="审核"
                    >
                      <el-option
                        v-for="s in subGroupsData"
                        :key="s.id"
                        :label="s.name"
                        :value="s.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="2" :offset="1">
                  <el-button
                    size="mini"
                    type="primary"
                    @click="examineChooseAll"
                    :disabled="isPermissionEdit"
                    style="margin-top: 5px"
                  >全选</el-button>
                </el-col>
                <!-- <el-col :span="4">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifReport"
                                        active-text="是否能发肿瘤报告"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifCytology"
                                        active-text="细胞学诊断"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifFrozen"
                                        active-text="冰冻诊断权限"
                                    />
                </el-col>-->
              </el-row>
              <el-row class="row-class">
                <el-col :span="11">
                  <el-form-item label="终审">
                    <el-select
                      v-model="finallExamine"
                      filterable
                      :disabled="isPermissionEdit"
                      :multiple="multiple"
                      size="mini"
                      style="width: 100%"
                      placeholder="终审"
                    >
                      <el-option
                        v-for="s in subGroupsData"
                        :key="s.id"
                        :label="s.name"
                        :value="s.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="2" :offset="1">
                  <el-button
                    size="mini"
                    type="primary"
                    @click="finallExamineChooseAll"
                    :disabled="isPermissionEdit"
                    style="margin-top: 5px"
                  >全选</el-button>
                </el-col>
                <!-- <el-col :span="4">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifReport"
                                        active-text="是否能发肿瘤报告"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifCytology"
                                        active-text="细胞学诊断"
                                    />
                                </el-col>
                                <el-col :span="3">
                                    <el-switch
                                        style="margin-top: 10px"
                                        v-model="ifFrozen"
                                        active-text="冰冻诊断权限"
                                    />
                </el-col>-->
              </el-row>
            </div>
          </el-tab-pane>
          <el-tab-pane label="扩展信息" name="extendedInformation">
            <span class="title-medium text-important">扩展信息</span>
            <el-row class="row-class">
              <el-col :span="8">
                <el-form-item label="签名照片">
                  <el-upload
                    :before-upload="beforeAvatarUpload"
                    :limit="1"
                    accept=".jpg, .png, .bmp"
                    class="avatar-uploader"
                    :action="userAvatorUrl"
                    ref="addItemDataUpload1"
                    :on-success="handleSignAvatarSuccess"
                    :show-file-list="false"
                    :drag="true"
                  >
                    <img
                      v-if="form.signUrl"
                      :src="
                                                imageServiceURL + form.signUrl
                                            "
                      class="avatar"
                      alt
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    <div
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="16" class="dimspace">
                <el-row class="row-padding-bottom">
                  <el-col :span="12">
                    <el-form-item label="电子邮箱" prop="email">
                      <el-input placeholder="电子邮箱" v-model="form.email" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="职级">
                      <el-select
                        v-model="form.position"
                        size="mini"
                        placeholder="请选择"
                        style="width: 100%"
                      >
                        <el-option
                          v-for="t in postKindData"
                          :key="t.id"
                          :label="t.dicName"
                          :value="t.dicCode"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row class="row-padding-bottom">
                  <el-col :span="12">
                    <el-form-item label="社会任职" prop="socialPosition">
                      <el-input placeholder="社会任职" v-model="form.socialPosition" size="mini" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="职称">
                      <el-select
                        v-model="form.medicalTitle"
                        size="mini"
                        placeholder="请选择"
                        style="width: 100%"
                      >
                        <el-option
                          v-for="t in titleData"
                          :key="t.id"
                          :label="t.dicName"
                          :value="t.dicCode"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row class="row-padding-bottom">
                  <el-col :span="12">
                    <el-form-item label="工龄" prop="workYear">
                      <el-input placeholder="工龄" v-model="form.workYear" size="mini" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row class="row-padding-bottom">
              <el-col class="dimspace">
                <el-form-item label="个人简介" prop="introduce">
                  <el-input
                    type="textarea"
                    :rows="3"
                    style="width: 100%"
                    placeholder="个人简介"
                    v-model="form.introduce"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="row-padding-bottom">
              <el-col class="dimspace">
                <el-form-item label="诊断特长" prop="speciality">
                  <el-input
                    type="textarea"
                    :rows="3"
                    placeholder="诊断特长"
                    v-model="form.speciality"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col class="dimspace">
                <el-form-item label="备注" prop="remark">
                  <el-input
                    type="textarea"
                    :rows="3"
                    style="width: 100%"
                    placeholder="备注"
                    v-model="form.remark"
                    size="mini"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="实名资质" name="realNameQualification">
            <span class="title-medium text-important">实名认证</span>
            <el-row class="row-class">
              <el-col :span="8">
                <el-form-item label="手持身份证照片">
                  <el-upload
                    :limit="2"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-change="changeIDRepos"
                    :file-list="idCardUrltemp"
                    :on-remove="changeIDRepos"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.idCardUrl"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传2张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传2张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="学历证书">
                  <el-upload
                    :before-upload="beforeAvatarUpload"
                    :limit="5"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changeDiplomaRepos"
                    :file-list="diplomaUrltemp"
                    :on-change="changeDiplomaRepos"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.diplomaUrl"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上5张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上5张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
            </el-row>
            <span class="title-medium text-important">资质认证</span>
            <el-row class="row-class">
              <el-col :span="8">
                <el-form-item label="医生执业证书编号正面">
                  <el-upload
                    :limit="1"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changeCFrontRepos"
                    :on-change="changeCFrontRepos"
                    :file-list="practiceUrlFtemp"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.practiceUrlF"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="医生执业证书编号反面">
                  <el-upload
                    :limit="1"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changeCVersoRepos"
                    :on-change="changeCVersoRepos"
                    :file-list="practiceUrlRtemp"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.practiceUrlR"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="医生执业证书编号" prop="practiceCode">
                  <el-input placeholder="医生职业证书编号" v-model="form.practiceCode" size="mini"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="医师资格证书编号正面">
                  <el-upload
                    :limit="1"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changeQFrontRepos"
                    :file-list="qualificationUrlFtemp"
                    :on-change="changeQFrontRepos"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.qualificationUrlF"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="医师资格证书编号反面">
                  <el-upload
                    :limit="1"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changeQVersoRepos"
                    :file-list="qualificationUrlRtemp"
                    :on-change="changeQVersoRepos"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.qualificationUrlR"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传1张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="医师资格证书编号" prop="qualificationCode">
                  <el-input placeholder="医师资格证书编号" v-model="form.qualificationCode" size="mini" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="医生工牌照片">
                  <el-upload
                    :limit="2"
                    :before-upload="beforeAvatarUpload"
                    accept=".jpg, .png, .bmp"
                    :action="userAvatorUrl"
                    :on-remove="changejobUrl"
                    :file-list="jobUrltemp"
                    :on-change="changejobUrl"
                    list-type="picture-card"
                    :drag="true"
                  >
                    <el-button size="mini" type="primary" style="margin-top: 57px">点击上传</el-button>
                    <div
                      v-if="form.jobUrl"
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: -15px"
                    >只能上传2张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                    <div
                      v-else
                      slot="tip"
                      class="el-upload__tip"
                      style="margin-top: 8px"
                    >只能上传2张{{ maxUploadFile }}M大小jpg/png/bmp文件</div>
                  </el-upload>
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <el-row justify="center" type="flex" style="margin-top: 20px">
        <el-button type="primary" @click="submitUser" size="mini">提交</el-button>
        <el-button size="mini" @click="goBack">取消</el-button>
      </el-row>
    </div>
  </div>
</template>

<script>
import _ from 'lodash';
import { vxRule } from '@/client/libs/validator';

export default {
  name: 'userInfo',
  data() {
    const checkPermission = (rule, value, callback) => {
      if (this.roles.length === 0) {
        return callback(new Error('请选择角色'));
      }
      return callback();
    };

    return {
      maxUploadFile: 1, //最大上传大小,单位M
      activeName: 'basicInformation', //当前所处tab页
      Permissionvalue: '',
      PermissionvalueID: '',
      innerPermission: [
        {
          level: 2,
          label: '初诊',
          type: ''
        },
        {
          level: 3,
          label: '核发',
          type: ''
        },
        {
          level: 4,
          label: '审核',
          type: ''
        },
        {
          level: 5,
          label: '终审',
          type: ''
        }
      ],
      idCardUrltemp: [], // 手持身份证照片URL展示
      practiceUrlFtemp: [], // 医师执业正面照url展示
      practiceUrlRtemp: [], // 医师执业反面照url展示
      qualificationUrlRtemp: [], // 医师资格反面照url展示
      qualificationUrlFtemp: [], // 医师资格正面照url展示
      jobUrltemp: [], // 医生工牌照片url
      diplomaUrltemp: [], // 学历证书URL
      // 诊断数据
      subGroupsData: [],
      // 诊断能否编辑
      isPermissionEdit: true,
      // 搜索的地区数据
      areaOptionsData: [],
      props: {
        value: 'id',
        label: 'name',
        children: 'childrenList'
      },
      // 所属机构
      institutionsData: [],
      // 获取用户所有角色
      userGroupsList: [],
      // 性别
      sexDate: [],
      // 上传地址后面写在配置文件里面
      imageServiceURL: process.env.ImageServiceURL,
      userAvatorUrl: `${process.env.ImageServiceURL}/upload`,
      // 初诊数据
      initialDiagnosis: [],
      // 核发数据
      approveIssues: [],
      // 审核数据
      examine: [],
      // 终审数据:
      finallExamine: [],
      // todo数据
      ifFrozen: true,
      ifCytology: true,
      ifReport: true,
      // 职级
      postKindData: [],
      // 职称
      titleData: [],
      // 区域,上传前还要处理
      area: [],
      // 角色,上传前还要处理
      roles: [],
      step: 1,
      form: {
        headUrl: '', // 用户头像URL
        signUrl: '', // 签名照片
        idCard: '', // 身份证号码
        name: '', // 用户姓名
        phone: '', // 用户电话
        institutionId: null, // 用户机构
        email: '', // 电子邮箱
        gender: null, // 性别ID
        education: '', // 学历
        major: '', // 专业
        jobNumber: '', // 医生工号
        socialPosition: '', // 社会任职
        workYear: '', // 工龄
        position: null, // 职级ID
        speciality: '', // 特长
        medicalTitle: null, // 职称ID
        introduce: '', // 个人简介
        remark: '', // 备注
        cityId: null, // 市区ID
        countyId: null, // 区县ID
        provinceId: null, // 省ID
        practiceCode: '', // 医生职业证书编号
        qualificationCode: '', // 医师资格证书编号
        idCardUrl: '', // 手持身份证照片URL
        practiceUrlF: '', // 医师执业正面照url
        practiceUrlR: '', // 医师执业反面照url
        qualificationUrlR: '', // 医师资格反面照url
        qualificationUrlF: '', // 医师资格正面照url
        jobUrl: '', // 医生工牌照片url
        diplomaUrl: '', // 学历证书URL
        roles: [], // 角色
        diagnosisPermissionVoList: [], // 诊断相关
        isFreezePermissions: 0, //该用户是否具有冰冻权限(0 : 否 ； 1 : 是)
        isDivisionConsultationApplyPermissions: 0, //该用户是否具有科内会诊申请权限(院内会诊申请)(0 : 否 ； 1 : 是)
        isOutsideConsultationApplyPermissions: 0, //该用户是否具有院外会诊申请权限(0 : 否 ； 1 : 是)
        isOutsideConsultationApplyDiagnosisPermissions: 0, //该用户是否具有院外会诊申请诊断权限(0 : 否 ； 1 : 是)
        isGynaecologyCellDiagnosisPermissions: 0, //该用户是否具有妇科细胞诊断权限(0 : 否 ； 1 : 是)
        isBiopsyRetrieval: 0
      },
      freezePermissionsList: [
        {
          id: 0,
          label: '否'
        },
        {
          id: 1,
          label: '是'
        }
      ],
      biopsyRetrievalPermissionsList: [
        {
          id: 0,
          label: '自己相关切片'
        },
        {
          id: 1,
          label: '所有切片'
        }
      ],
      stepOneFormRules: {
        name: [
          vxRule(true, null, 'blur', '请填写姓名'),
          vxRule(true, 'length', 'blur', '姓名填写请不要超过20个字符', null, 20)
        ],
        email: [
          vxRule(false, 'email', 'blur', '请输入正确的电子邮箱'),
          vxRule(
            false,
            'length',
            'blur',
            '请输入电子邮箱的长度小于50个字符',
            null,
            50
          )
        ],
        socialPosition: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入社会任职的长度小于50个字符',
            null,
            50
          )
        ],
        speciality: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入特长的长度小于50个字符',
            null,
            50
          )
        ],
        major: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入专业的长度小于50个字符',
            null,
            50
          )
        ],
        education: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入专业的长度小于255个字符',
            null,
            255
          )
        ],
        introduce: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入个人简介的长度小于255个字符',
            null,
            255
          )
        ],
        remark: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入备注的长度小于255个字符',
            null,
            255
          )
        ],
        workYear: [
          vxRule(false, 'int', 'blur', '请输入正确的工龄'),
          vxRule(
            false,
            'length',
            'blur',
            '请输入工龄的长度小于2位数字',
            null,
            2
          )
        ],
        phone: [vxRule(true, 'mobile', 'blur', '请输入正确的手机')],
        idCard: [vxRule(true, 'idCard', 'blur', '请输入正确的身份证号')],
        jobNumber: [vxRule(true, null, 'blur', '请输入正确的医生工号')],
        practiceCode: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入医生执业证书编号的长度小于50个字符',
            null,
            50
          )
        ],
        qualificationCode: [
          vxRule(
            false,
            'length',
            'blur',
            '请输入医师资格证书编号的长度小于50个字符',
            null,
            50
          )
        ],
        roles: [
          {
            required: true,
            validator: checkPermission,
            trigger: 'blur'
          }
        ]
      },
      multiple: true
    };
  },
  watch: {
    area: function(newValue, oldValue) {
      if (newValue.length === 0) {
        this.area = [];
        this.form.area = '';
        this.form.provinceId = null;
        this.form.cityId = null;
        this.form.countyId = null;
        this.form.provinceName = '';
        this.form.cityName = '';
        this.form.countyName = '';
      }
    }
  },
  created() {
    // 获取通用权限ID
    try {
      this.$axios({
        method: 'get',
        url: '/PROXY-Remote/subgroups/special'
      }).then(res2 => {
        if (res2 && res2.data.code === 200 && res2.data.data != null) {
          const result = res2.data.data;
          const PermissionvalueID = result.id;
          this.getTableData(PermissionvalueID);
        } else {
          this.getTableData();
        }
      });
    } catch (e) {
      console.log('请求失败');
    }
  },
  mounted() {
    // 数据初始化-------------
    // 用户机构
    this.getInstitutionsDate();
    // 行政区域数据初
    this.getareaOptionsData();
    // 获取角色列表
    this.getuserGroupsList();
    // 获取性别
    this.getsexData();
    // 获取诊断数据列表
    this.getsubGroupsDataList();
    // 获取职级
    this.getPostKind();
    // 获取职称
    this.getTitleForClinic();
    // 获取通用诊断ID
    this.getPermissionvalueID();
  },

  methods: {
    beforeAvatarUpload(file) {
      if (file.size / 1024 / 1024 > this.maxUploadFile) {
        this.$message.warning({
          message: `图片大于${this.maxUploadFile}M, 请重新选择`
        });
        return false;
      }
    },
    // 获取表格数据并处理
    getTableData(PermissionvalueID) {
      const id = this.$store.state.userID;
      try {
        this.$axios({
          method: 'get',
          url: `/PROXY-Remote/users/${id}`,
          params: {}
        }).then(res => {
          if (res && res.data.code === 200) {
            // 处理接收的数据
            this.form = res.data.data.userInfo;
            // 处理所在地
            this.area.push(res.data.data.userInfo.provinceId);
            this.area.push(res.data.data.userInfo.cityId);
            this.area.push(res.data.data.userInfo.countyId);
            // 处理角色
            res.data.data.userInfo.roleVoList.forEach(ele => {
              this.roles.push(ele.roleId);
            });
            // 初始化诊断是否可编辑
            this.ifEditPermission(this.roles);
            // 处理院内诊断权限（诊断组）
            if (PermissionvalueID) {
              res.data.data.userInfo.diagnosisPermissionVoList.forEach(ele => {
                if (PermissionvalueID === ele.subgroupId) {
                  this.Permissionvalue = ele.diagnosisLevelVoList[0].level;
                }
                ele.diagnosisLevelVoList.forEach(temp => {
                  if (
                    temp.level === 2 &&
                    PermissionvalueID !== ele.subgroupId
                  ) {
                    this.initialDiagnosis.push(ele.subgroupId);
                  }
                  if (
                    temp.level === 3 &&
                    PermissionvalueID !== ele.subgroupId
                  ) {
                    this.approveIssues.push(ele.subgroupId);
                  }
                  if (
                    temp.level === 4 &&
                    PermissionvalueID !== ele.subgroupId
                  ) {
                    this.examine.push(ele.subgroupId);
                  }
                  if (
                    temp.level === 5 &&
                    PermissionvalueID !== ele.subgroupId
                  ) {
                    this.finallExamine.push(ele.subgroupId);
                  }
                });
              });
              this.initialDiagnosis = _.uniq(this.initialDiagnosis);
              this.approveIssues = _.uniq(this.approveIssues);
              this.examine = _.uniq(this.examine);
              this.finallExamine = _.uniq(this.finallExamine);
            } else {
              this.$message('院内诊断权限获取失败');
            }

            // 处理图片链接
            if (res.data.data.userInfo.idCardUrl) {
              res.data.data.userInfo.idCardUrl.split('|').forEach(tem => {
                if (tem) {
                  this.idCardUrltemp.push({
                    name: '',
                    url: this.imageServiceURL + tem
                  });
                }
              });
            }
            if (res.data.data.userInfo.practiceUrlF) {
              res.data.data.userInfo.practiceUrlF.split('|').forEach(tem => {
                if (tem) {
                  this.practiceUrlFtemp.push({
                    name: '',
                    url: this.imageServiceURL + tem
                  });
                }
              });
            }
            if (res.data.data.userInfo.practiceUrlR) {
              res.data.data.userInfo.practiceUrlR.split('|').forEach(tem => {
                if (tem) {
                  this.practiceUrlRtemp.push({
                    name: '',
                    url: this.imageServiceURL + tem
                  });
                }
              });
            }
            if (res.data.data.userInfo.qualificationUrlR) {
              res.data.data.userInfo.qualificationUrlR
                .split('|')
                .forEach(tem => {
                  if (tem) {
                    this.qualificationUrlRtemp.push({
                      name: '',
                      url: this.imageServiceURL + tem
                    });
                  }
                });
            }
            if (res.data.data.userInfo.qualificationUrlF) {
              res.data.data.userInfo.qualificationUrlF
                .split('|')
                .forEach(tem => {
                  if (tem) {
                    this.qualificationUrlFtemp.push({
                      name: '',
                      url: this.imageServiceURL + tem
                    });
                  }
                });
            }
            if (res.data.data.userInfo.jobUrl) {
              res.data.data.userInfo.jobUrl.split('|').forEach(tem => {
                if (tem) {
                  this.jobUrltemp.push({
                    name: '',
                    url: this.imageServiceURL + tem
                  });
                }
              });
            }
            if (res.data.data.userInfo.diplomaUrl) {
              res.data.data.userInfo.diplomaUrl.split('|').forEach(tem => {
                if (tem) {
                  this.diplomaUrltemp.push({
                    name: '',
                    url: this.imageServiceURL + tem
                  });
                }
              });
            }
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },

    // 初始化诊断能否编辑待调用
    ifStartEditPermission() {
      this.isPermissionEdit = true;
      const { roles } = this;
      for (let i = 0, len = roles.length; i < len; i++) {
        for (let j = 0, len2 = this.userGroupsList.length; j < len2; j++) {
          if (roles[i] === this.userGroupsList[j].id) {
            if (
              this.userGroupsList[j].data &&
              this.userGroupsList[j].data.permissions
            ) {
              for (
                let k = 0,
                  len3 = this.userGroupsList[j].data.permissions.length;
                k < len3;
                k++
              ) {
                if (
                  this.userGroupsList[j].data.permissions[k].code === 'diagnose'
                ) {
                  this.isPermissionEdit = false;
                  return null;
                }
              }
            }
          }
        }
      }
      if (this.isPermissionEdit) {
        this.$message.info('该角色下诊断组不可编辑');
      }
      return null;
    },
    initialDiagnosisChooseAll() {
      const alreadyChooseItems = this.initialDiagnosis;
      this.subGroupsData.forEach(item => {
        if (_.indexOf(alreadyChooseItems, item.id) === -1) {
          this.initialDiagnosis.push(item.id);
        }
      });
    },
    approveIssuesChooseAll() {
      const alreadyChooseItems = this.approveIssues;
      this.subGroupsData.forEach(item => {
        if (_.indexOf(alreadyChooseItems, item.id) === -1) {
          this.approveIssues.push(item.id);
        }
      });
    },
    examineChooseAll() {
      const alreadyChooseItems = this.examine;
      this.subGroupsData.forEach(item => {
        if (_.indexOf(alreadyChooseItems, item.id) === -1) {
          this.examine.push(item.id);
        }
      });
    },
    finallExamineChooseAll() {
      const alreadyChooseItems = this.finallExamine;
      this.subGroupsData.forEach(item => {
        if (_.indexOf(alreadyChooseItems, item.id) === -1) {
          this.finallExamine.push(item.id);
        }
      });
    },
    // 判断诊断能否编辑
    ifEditPermission(val) {
      this.isPermissionEdit = true;
      for (let i = 0, len = val.length; i < len; i++) {
        for (let j = 0, len2 = this.userGroupsList.length; j < len2; j++) {
          if (val[i] === this.userGroupsList[j].id) {
            if (
              this.userGroupsList[j].data &&
              this.userGroupsList[j].data.permissions
            ) {
              for (
                let k = 0,
                  len3 = this.userGroupsList[j].data.permissions.length;
                k < len3;
                k++
              ) {
                if (
                  this.userGroupsList[j].data.permissions[k].code === 'diagnose'
                ) {
                  this.isPermissionEdit = false;
                  return null;
                }
              }
            }
          }
        }
      }
      // 没有诊断权限数据清空
      if (this.isPermissionEdit) {
        // 初诊数据
        this.initialDiagnosis = [];
        // 核发数据
        this.approveIssues = [];
        // 审核数据
        this.examine = [];
        // 终审数据:
        this.finallExamine = [];
        this.form.isFreezePermissions = 0;
        this.form.isDivisionConsultationApplyPermissions = 0;
        this.form.isOutsideConsultationApplyPermissions = 0;
        this.form.isOutsideConsultationApplyDiagnosisPermissions = 0;
        this.form.isGynaecologyCellDiagnosisPermissions = 0;
        this.form.isBiopsyRetrieval = 0;
      }
      return null;
    },
    // 获取字典职级数据 职级
    getPostKind() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/dicts/list',
          params: {
            code: 'PostKind'
          }
        }).then(res => {
          if (res && res.data.code === 200) {
            res.data.data.forEach(element => {
              this.postKindData.push({
                dicName: element.name,
                dicCode: element.id
              });
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 查找字典职称数据
    getTitleForClinic() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/dicts/list',
          params: {
            code: 'TitleForClinic'
          }
        }).then(res => {
          if (res && res.data.code === 200) {
            res.data.data.forEach(element => {
              this.titleData.push({
                dicName: element.name,
                dicCode: element.id
              });
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 获取诊断数据列表
    getsubGroupsDataList() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/subgroups',
          params: {}
        }).then(res => {
          if (res && res.data.code === 200) {
            res.data.data.forEach(element => {
              this.subGroupsData.push({
                id: element.id,
                name: element.name
              });
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 获取性别
    getsexData() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/dicts/list',
          params: {
            code: 'SexKind'
          }
        }).then(res => {
          if (res && res.data.code === 200) {
            res.data.data.forEach(element => {
              this.sexDate.push({
                dicName: element.name,
                dicCode: element.id
              });
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 获取角色列表
    getuserGroupsList() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/roles',
          params: {}
        }).then(res => {
          if (res && res.data.code === 200) {
            res.data.data.forEach(element => {
              this.userGroupsList.push({
                id: element.id,
                name: element.name,
                data: element
              });
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 获取行政区域数据
    getareaOptionsData() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/provinces',
          params: {}
        }).then(res => {
          if (res && res.data.code === 200) {
            this.areaOptionsData = res.data.data;
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
    },
    // 获取所需机构I
    getInstitutionsDate() {
      try {
        this.$axios({
          method: 'get',
          url: `/PROXY-Remote/institutions/${this.$store.state.institution.id}`,
          params: {}
        }).then(res => {
          if (res && res.data.code === 200) {
            this.institutionsData.push({
              value: res.data.data.id,
              label: res.data.data.name
            });
          }
        });
      } catch (e) {
        console.log(`请求失败  ${e}`);
      }
      return '';
    },
    // 回到页面顶部
    goBackTop() {
      document.body.scrollTop = 0;
      document.documentElement.scrollTop = 0;
    },
    // 验证工号唯一
    checkWorkNumberOnly() {
      return false;
    },
    // 检查手机号唯一
    checkPhoneOnly() {
      return false;
    },
    addOrganization() {
      // Meteor.call('organization.add', {});
    },
    submitForm() {
      let decide = false;
      this.$refs.form.validate(valid => {
        if (valid) {
          decide = true;
        } else {
          this.$message('请将信息填写完整');
        }
      });
      return decide;
    },
    next() {
      if (this.step > 3) {
        return false;
      }
      if (this.submitForm() === true) {
        this.step += 1;
        this.goBackTop();
      }
      return '';
    },
    back() {
      if (this.step < 1) {
        return false;
      }

      this.step -= 1;
      this.goBackTop();
      return null;
    },
    jump2list() {
      this.$router.push('/users');
    },
    // 用户头像图片
    handleAvatarSuccess(res) {
      if (res.status === 'success') {
        this.form.headUrl = res.url.slice(res.url.indexOf('_') - 1);
        this.$refs.addItemDataUpload.clearFiles();
      }
    },
    // 签名照片图片
    handleSignAvatarSuccess(res) {
      if (res.status === 'success') {
        this.form.signUrl = res.url.slice(res.url.indexOf('_') - 1);
        this.$refs.addItemDataUpload1.clearFiles();
      }
    },
    changeIDRepos(file, fileList) {
      this.form.idCardUrl = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.idCardUrl += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.idCardUrl += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changeDiplomaRepos(file, fileList) {
      this.form.diplomaUrl = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.diplomaUrl += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.diplomaUrl += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changeCFrontRepos(file, fileList) {
      this.form.practiceUrlF = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.practiceUrlF += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.practiceUrlF += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changeCVersoRepos(file, fileList) {
      this.form.practiceUrlR = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.practiceUrlR += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.practiceUrlR += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changeQFrontRepos(file, fileList) {
      this.form.qualificationUrlF = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.qualificationUrlF += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.qualificationUrlF += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changeQVersoRepos(file, fileList) {
      this.form.qualificationUrlR = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.qualificationUrlR += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.qualificationUrlR += `${ele.url.slice(
              ele.url.indexOf('_') - 1
            )}|`;
          }
        });
      }
    },
    changejobUrl(file, fileList) {
      this.form.jobUrl = '';
      if (file.status === 'success') {
        fileList.forEach(ele => {
          if (ele.response) {
            this.form.jobUrl += `${ele.response.url.slice(
              ele.response.url.indexOf('_') - 1
            )}|`;
          } else {
            this.form.jobUrl += `${ele.url.slice(ele.url.indexOf('_') - 1)}|`;
          }
        });
      }
    },
    submitUser() {
      // 前端数据为null给后端,后端会做处理
      // 处理参数,处理的参数为必填项目
      if (this.validateForm()) {
        this.doSubmitPrarm();
        try {
          this.$axios({
            method: 'put',
            url: '/PROXY-Remote/users',
            data: this.form,
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(
            res => {
              if (res && res.data.code === 200) {
                this.goBack();
                this.$message.success('更新成功');
              } else {
                this.$message.error(res.data.message);
              }
            },
            err => {
              this.$message.info(`更新失败  ${err.response.data.message}`);
            }
          );
        } catch (e) {
          console.log(`请求失败  ${e}`);
        }
      }
    },
    // 获取通用权限的ID
    getPermissionvalueID() {
      try {
        this.$axios({
          method: 'get',
          url: '/PROXY-Remote/subgroups/special'
        }).then(res => {
          if (res && res.data.code === 200) {
            const result = res.data.data;
            this.PermissionvalueID = result.id;
          }
        });
      } catch (e) {
        console.log('请求失败');
      }
    },
    // 处理提交参数
    doSubmitPrarm() {
      // 处理区县数据
      if (this.area.length > 0) {
        [
          this.form.provinceId,
          this.form.cityId,
          this.form.countyId
        ] = this.area;
      }
      // 处理角色权限
      this.form.roles = [];
      if (this.roles.length > 0) {
        this.roles.forEach(ele => {
          const role = { id: ele };
          this.form.roles.push(role);
        });
      }
      // 处理诊断组数据
      this.form.diagnosisPermissionVoList = [];
      // 处理通用权限
      if (this.Permissionvalue !== '' && this.Permissionvalue !== null) {
        this.form.diagnosisPermissionVoList.push({
          diagnosisLevelVoList: [
            {
              level: this.Permissionvalue
            }
          ],
          subgroupId: this.PermissionvalueID
        });
      }
      // 处理诊断组数据
      // 初诊
      if (this.initialDiagnosis.length > 0) {
        this.initialDiagnosis.forEach(ele => {
          this.form.diagnosisPermissionVoList.push({
            diagnosisLevelVoList: [
              {
                level: 2
              }
            ],
            subgroupId: ele
          });
        });
      }
      // 核发
      if (this.approveIssues.length > 0) {
        this.approveIssues.forEach(ele => {
          this.form.diagnosisPermissionVoList.push({
            diagnosisLevelVoList: [
              {
                level: 3
              }
            ],
            subgroupId: ele
          });
        });
      }
      // 审核
      if (this.examine.length > 0) {
        this.examine.forEach(ele => {
          this.form.diagnosisPermissionVoList.push({
            diagnosisLevelVoList: [
              {
                level: 4
              }
            ],
            subgroupId: ele
          });
        });
      }
      // 终审
      if (this.finallExamine.length > 0) {
        this.finallExamine.forEach(ele => {
          this.form.diagnosisPermissionVoList.push({
            diagnosisLevelVoList: [
              {
                level: 5
              }
            ],
            subgroupId: ele
          });
        });
      }
    },
    goBack() {
      this.$router.go(-1);
    },
    validateForm() {
      let decide = false;
      this.$refs.refForm.validate(valid => {
        if (valid) {
          decide = true;
        } else {
          this.activeName = 'basicInformation';
        }
      });
      return decide;
    }
  },

  computed: {
    // 院内诊断只有一个机构
    isOrgAdmin() {
      return true;
    }
  }
};
</script>

<style scoped>
.success-page div {
  text-align: center;
  margin-top: 60px;
}

.success-page .success-icon {
  font-size: 80px;
  color: #67c23a;
}

.success-page .success-h1 {
  font-size: 40px;
  color: #67c23a;
}

.success-page .success-h2 {
  font-size: 18px;
}

.row-class {
  margin-top: 20px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 146px;
  height: 146px;
  line-height: 146px;
  text-align: center;
}

.avatar {
  width: 146px;
  height: 146px;
  display: block;
}

.add-board.main-container .el-steps.el-steps--simple {
  width: 400px;
  margin: auto;
}
.row-margin-left {
  margin-left: 82px;
}
.row-padding-bottom {
  padding-bottom: 10px;
}
.row-padding-role {
  padding-bottom: 16px;
}
</style>
